package com.xbongbong.saas.model;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.saas.domain.entity.BusinessProductEntity;
import com.xbongbong.saas.domain.entity.WorkOrderProductEntity;

import java.util.List;
import java.util.Map;

/**
 *
 * @author 刘阳
 * @date 2019/4/23 3:44 PM
 * @since v1.0
 * @version v1.0
 */
public interface WorkOrderProductModel extends IModel<WorkOrderProductEntity> {
    @Override
    Integer insert(WorkOrderProductEntity entity) throws XbbException;


    /**
     * 批量插入
     * @param productAddList
     * @return
     */
    Integer insertBatch(List<WorkOrderProductEntity> productAddList);


    @Override
    Integer update(WorkOrderProductEntity entity) throws XbbException;

    @Override
    List<WorkOrderProductEntity> findEntitys(Map<String, Object> param);

    WorkOrderProductEntity getByKey(Long key, String corpid);

    Integer save(WorkOrderProductEntity entity) throws XbbException;

    List<WorkOrderProductEntity> getProductsByWorkOrderId(Long workOrderId, String corpid);

    List<WorkOrderProductEntity> getProductsByWorkOrderId(Long workOrderId, String corpid, List<Integer> delIn);

    /**
     * Description:批量删除
     * @param workOrderIdIn
     * @param corpid
     * @return java.lang.Integer
     * @throws XbbException
     * @author 魏荣杰
     * @date 2019/5/9 11:02
     * @since v1.0
     */
    Integer deleteByWorkOrderIdIn(List<Long> workOrderIdIn, String corpid) throws XbbException;

    List<BusinessProductEntity> findProductNum(Map<String,Object> param);

    /**
     * Description: 批量删除
     * @param list id列表
     * @param corpid 公司id
     * @param del   删除标志
     * @return Integer
     * @throws XbbException XbbException
     * @author 刘阳
     * @date 2019/9/25 7:15 PM
     * @since v1.0
     */
    Integer deleteBatch(List<Long> list, String corpid, Integer del) throws XbbException;

    Integer updateBatch(List<WorkOrderProductEntity> list, String corpid);

    /**
     * 批量编辑
     * @param updateList
     * @param corpid
     * @return
     * @throws XbbException
     */
    Integer updateMulti(List<WorkOrderProductEntity> updateList, String corpid) throws XbbException;

    Integer updateOutstockBatch(List<WorkOrderProductEntity> list, String corpid);

    Integer findProductNumCount(Map<String, Object> param);

    List<BusinessProductEntity> findProductNumIncludeProcess(Map<String,Object> param);

    Integer findProductNumCountIncludeProcess(Map<String,Object> param);

    Long isProductSubAttrExist(String attr, String corpid, Long formId, Integer isArray);

    /**
     * 子表单数字字段汇总
     * @param corpid 公司id
     * @param field 需要汇总的字段
     * @param refId 单据id
     * @param productIdIn 单据在该产品关联的产品id 如生产单有物料产品和成品产品 refId为生产单id productIdIn为物料产品的id
     * @return
     */
    Double summaryByAttr(String field,String corpid, Long refId, List<Long> productIdIn);

    List<String> getCorpidList();

    Double summaryByAttrFromOutSide(String field,String corpid, Long refId, List<Long> productIdIn);

    Double calcuateByAttrFromOutSide(String field1, String field2, String corpid, Long refId, List<Long> productIdIn);

    Long countProductSub(String attr, String corpid, Long formId, Integer isArray);

    List<WorkOrderProductEntity> getProductWithSubData(String attr, String corpid, Long formId, Integer isArray, Long idGte, Integer limit);
}
